package com.igeekhome.shopservice.controller;

import com.igeekhome.shop.pojo.TbItem;
import com.igeekhome.shopservice.service.IItemService;
import com.igeekhome.shopservice.vo.ItemAddVo;
import com.igeekhome.shopservice.vo.ItemQueryVo;
import com.igeekhome.util.CustomPageInfo;
import com.igeekhome.util.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("item")
@RestController
public class ItemController {
    @Resource
    private IItemService iItemService;

    @RequestMapping("list")

    public ResponseEntity list(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer limit, ItemQueryVo query){
        CustomPageInfo customPageInfo = iItemService.selectAll(page, limit, query);
        return ResponseEntity.success(customPageInfo);
    }


    @RequestMapping("add")

    public ResponseEntity add(@RequestBody ItemAddVo item){
        iItemService.addItemAndDesc(item);
        return ResponseEntity.success();
    }

}
